package leetcode.median;

/**
 * ClassName: $287_FindDuplicate
 * Description:
 * date: 2022-02-17 16:05
 *
 * @author liyifan
 */
public class $287_FindDuplicate {
    public int findDuplicate(int[] nums) {
        int slow = 0;
        int fast = 0;
        while (true) {
            slow = nums[slow];
            fast = nums[nums[fast]];
            if (slow == fast)
                break;
        }
        int find = 0;
        while (find != slow) {
            find = nums[find];
            slow = nums[slow];

        }
        return find;
    }
}
